package com.example.demo.receiver;

import com.example.demo.Order;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class CustomReceiver {
    @RabbitListener(queues = "delay_queue_2")
    public void receive(Order order) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
        System.out.println("消息接收时间：" + sdf.format(new Date()));
        System.out.println("执行取消订单的操作");
        //乐观锁取消订单
        System.out.println("订单信息如下:\n");
        System.out.println(order.getOrderNo()+","+order.getUsername()+","+order.getAmount());
    }
}
